package com.wanli.agent.mine;

import android.os.Bundle;
import android.widget.TextView;

import com.wanli.agent.R;
import com.wanli.agent.base.BaseActivity;
import com.wanli.agent.base.DataCallBack;
import com.wanli.agent.bean.RateNewBean;
import com.wanli.agent.homepage.model.HomePageModelImpl;
import com.wanli.agent.homepage.model.IHomePageModel;
import com.wanli.agent.widget.AppTitleBar;

import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

public class MySettlePriceActivity extends BaseActivity {
    @BindView(R.id.title_bar)
    AppTitleBar titleBar;
    @BindView(R.id.edit_debit_card_value)
    TextView editDebitCardValue;
    @BindView(R.id.edit_quickpass_debit_value)
    TextView editQuickpassDebitValue;
    @BindView(R.id.edit_debit_card_cap_value)
    TextView editDebitCardCapValue;
    @BindView(R.id.edit_credit_card_value)
    TextView editCreditCardValue;
    @BindView(R.id.edit_quickpass_credit_value)
    TextView editQuickpassCreditValue;
    @BindView(R.id.edit_wechat_alipay_value)
    TextView editWechatAlipayValue;
    @BindView(R.id.edit_wechat_alipay_d0_value)
    TextView editWechatAlipayD0Value;
    @BindView(R.id.edit_waiver_value)
    TextView editWaiverValue;
    @BindView(R.id.edit_huabei_value)
    TextView editHuabeiValue;
    private IHomePageModel homePageModel;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_my_settle_price);
        ButterKnife.bind(this);
        initView();
    }

    public void initView() {
        homePageModel = new HomePageModelImpl();
        requestShareMoneyRateNewMy();
    }

    public void requestShareMoneyRateNewMy() {
        homePageModel.requestShareMoneyRateNewMy(new DataCallBack<RateNewBean>() {
            @Override
            public void onSuccessful(RateNewBean bean) {
                setRateNewMy(bean);
            }

            @Override
            public void onFailed(String msg, String code) {

            }
        });
    }

    public void setRateNewMy(RateNewBean bean) {
        List<RateNewBean.DataBean> mList = bean.getData();
        for (RateNewBean.DataBean dataBean : mList) {
            switch (dataBean.getRule_type()) {
                case 1:
                    editWaiverValue.setText(dataBean.getRate() + "%");
                    break;
                case 2:
                    editWechatAlipayValue.setText(dataBean.getRate() + "%");
                    break;
                case 3:
                    editQuickpassDebitValue.setText(dataBean.getRate() + "%");
                    break;
                case 4:
                    editQuickpassCreditValue.setText(dataBean.getRate() + "%");
                    break;
                case 5:
                    editDebitCardValue.setText(dataBean.getRate() + "%");
                    break;
                case 6:
                    editDebitCardCapValue.setText(dataBean.getRate() + "元");
                    break;
                case 7:
                    editCreditCardValue.setText(dataBean.getRate() + "%");
                    break;
                case 8:
                    editWechatAlipayD0Value.setText(dataBean.getRate() + "%");
                    break;
                case 13:
                    editHuabeiValue.setText(dataBean.getRate() + "%");
                    break;

            }
        }
    }
}
